﻿#region << 版 本 注 释 >>
/*----------------------------------------------------------------
 * 创建者：王明亮
 * 创建时间：2022/8/16 18:28:08
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/
#endregion << 版 本 注 释 >>

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;
using System.Linq;
using System.Text;


namespace Aliang.DB.Helper.Oracle
{
    /// <summary>
    /// OracleDBHelper 的摘要说明
    /// </summary>
    public class OracleDBHelper
    {
        //Oracle 数据库连接
        private static readonly string ConnectionString = ConfigurationManager.ConnectionStrings["OracleDataSource"].ConnectionString;


        private static DataTable GetDataTable(OracleConnection conn, string sql, int timeOut = 40)
        {
            var cmd = new OracleCommand(sql, conn) { CommandType = CommandType.Text, CommandTimeout = timeOut };
            var da = new OracleDataAdapter(cmd);
            var dt = new DataTable("dataTable");
            da.Fill(dt);
            return dt;
        }

        private static void ExecuteNonQuery(OracleConnection conn, CommandType commandType, string sql, OracleParameter[] paras, int timeOut = 40)
        {
            var cmd = new OracleCommand(sql, conn) { CommandType = commandType, CommandTimeout = timeOut };
            cmd.Parameters.AddRange(paras);
            cmd.ExecuteNonQuery();
        }

        private static void ExecuteNonQuery(OracleConnection conn, OracleTransaction tran, string sql)
        {
            var cmd = new OracleCommand(sql, conn) { CommandType = CommandType.Text, Transaction = tran };
            cmd.ExecuteNonQuery();
        }
        private static void ExecuteNonQuery(OracleConnection conn, CommandType commandType, string sql, int timeOut = 40)
        {
            var cmd = new OracleCommand(sql, conn) { CommandType = CommandType.Text, CommandTimeout = timeOut };
            cmd.ExecuteNonQuery();
        }
        private static OracleDataReader ExecuteDataReader(OracleConnection conn, string sql, int timeOut = 40)
        {
            var cmd = new OracleCommand(sql, conn) { CommandType = CommandType.Text, CommandTimeout = timeOut };
            return cmd.ExecuteReader();
        }
    }
}
